package com.huatai.datacenter.controller.datamodel;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.huatai.common.api.R;
import com.huatai.datacenter.entity.datamodel.DataModelTypeEntity;
import com.huatai.datacenter.service.DataModelTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author gusiyi
 * @version 1.0
 * @className DataModelTypeController
 * @description 描述：
 * @date 2023/5/25 14:57
 */
@RestController
@RequestMapping("/dataModel/type")
@Api(value = "数据模型类型操作", tags = "数据模型类型")
public class DataModelTypeController {

	@Autowired
	private DataModelTypeService dataModelTypeService;


	@RequestMapping("/getList")
	@ApiOperation(value = "获取数据模型类型清册")
	@ApiOperationSupport(order = 1, includeParameters = {
		"dataModelTypeEntity.name",
		"dataModelTypeEntity.pageIndex",
		"dataModelTypeEntity.pageSize"
	})
	public R<Page<DataModelTypeEntity>> getModelTypeList(@RequestBody DataModelTypeEntity dataModelTypeEntity){
		Page<DataModelTypeEntity> dataModelTypeEntityPage = dataModelTypeService.getModelTypeList(dataModelTypeEntity);
		return R.data(dataModelTypeEntityPage,"获取数据模型清册成功");
	}

	@RequestMapping("/saveOne")
	@ApiOperation(value = "保存数据模型类型",notes = "dataModelTypeEntity")
	@ApiOperationSupport(order = 2, includeParameters = {
		"dataModelTypeEntity.name",
		"dataModelTypeEntity.remark"
	})
	public R<Boolean> insertOne(@RequestBody DataModelTypeEntity dataModelTypeEntity){
		return R.status(dataModelTypeService.save(dataModelTypeEntity));
	}

	@RequestMapping("/updateById")
	@ApiOperation(value = "修改数据模型类型",notes = "dataModelTypeEntity")
	@ApiOperationSupport(order = 3, includeParameters = {
		"dataModelTypeEntity.id",
		"dataModelTypeEntity.name",
		"dataModelTypeEntity.remark"
	})
	public R<Boolean> updateById(@RequestBody DataModelTypeEntity dataModelTypeEntity){
		dataModelTypeEntity.setUpdateTime(null);
		dataModelTypeEntity.setUpdateUserid(null);
		dataModelTypeEntity.setDeleted(null);
		return R.status(dataModelTypeService.updateModelType(dataModelTypeEntity));
	}

	@RequestMapping("/deleteByIds")
	@ApiOperation(value = "删除数据模型类型",notes = "dataModelTypeEntityIds")
	@ApiOperationSupport(order = 4, includeParameters = {
		"dataModelTypeEntityIds.id"
	})
	public R<Boolean> deletedById(@RequestBody List<DataModelTypeEntity> dataModelTypeEntityIds){
		return R.status(dataModelTypeService.deleteByIds(dataModelTypeEntityIds));
	}


}
